package com.playcrab.adouban;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;

public class User  extends TabActivity {
    /** Called when the activity is first created. */
	 private TabHost tabs;

    private static final String LOG_TAG = "User";
        
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user);
        
        
        Bundle bundle = this.getIntent().getExtras();
        String type = bundle.getString("type");
        String id = bundle.getString("id");
        Log.v(LOG_TAG,"type:"+type); 
        Log.v(LOG_TAG,"id:"+id); 

		 
		if(type == null)
			 type = "user"; 
		
		setTitle(id);
        
        
        tabs = getTabHost();        
        TabHost.TabSpec infoTab = tabs.newTabSpec("user");
        Intent user = new Intent(this, ViewUser.class);
        
        user.putExtra("id", id);
        infoTab.setContent(user);
        infoTab.setIndicator(getString(R.string.info), this.getResources().getDrawable(R.drawable.user_32));
        tabs.addTab(infoTab);

        TabHost.TabSpec friendsTab = tabs.newTabSpec("friends");
        Intent friends = new Intent(this, FriendList.class);
        friends.putExtra("type", "friends");
        friends.putExtra("id", id);
        friendsTab.setContent(friends);
        friendsTab.setIndicator(getString(R.string.friends), this.getResources().getDrawable(R.drawable.friends_32));
        tabs.addTab(friendsTab);
        
        TabHost.TabSpec contactsTab = tabs.newTabSpec("contacts");
        Intent contacts = new Intent(this, FriendList.class);
        contacts.putExtra("type", "contacts");
        contacts.putExtra("id", id);
        
        contactsTab.setContent(contacts);
        contactsTab.setIndicator(getString(R.string.contacts), this.getResources().getDrawable(R.drawable.contacts_32));
        tabs.addTab(contactsTab);
        
        
          
		 
        if(type.equalsIgnoreCase("user")){
        	tabs.setCurrentTab(0);
        }else if(type.equalsIgnoreCase("friends")){
        	tabs.setCurrentTab(1);
        }
        else if(type.equalsIgnoreCase("contacts")){
            	tabs.setCurrentTab(2);
        }else{
        	tabs.setCurrentTab(0);
        }
          
		
    }
       
}